<template>
  <a-card :bordered="false">
    <div class="title_blue">账套管理</div>
    <div class="title_black">购买记录</div>
    <div class="divider_line"></div>
    <div>
      <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading"
       class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="goodsNumber" slot-scope="text, record">
          <div v-if="record.goodsType == 1">{{ text }}年</div>
          <div v-else-if="record.goodsType == 2">{{ text }}用户</div>
          <div v-else-if="record.goodsType == 3">{{ text }}单</div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <template slot="noteSlot" slot-scope="text, record">
          <j-ellipsis :value="text" :length="15" />
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
        </span>

      </a-table>
    </div>

  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'

export default {
  name: 'PurchaseHistory',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    
  },
  data() {
    return {
      description: '授权中心订单管理页面',
      // 表头
      columns: [
        // {
        //   title: '序号',
        //   dataIndex: '',
        //   key: 'rowIndex',
        //   width: 60,
        //   align: "center",
        //   customRender: function (t, r, index) {
        //     return parseInt(index) + 1;
        //   }
        // },
        {
          title: '订单日期',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '订单号',
          align: "center",
          dataIndex: 'orderNumber'
        },
        {
          title: '商品名称',
          align: "center",
          dataIndex: 'goodsName'
        },
        {
          title: '订单明细',
          align: "center",
          dataIndex: 'userNumBack',
          customRender: function (t, r, index) {
            if (r.goodsType == 1) {
                // 账套升级
                let showData = r.showData
                if (!showData || showData == 'null') {
                  showData = (r.yearNum || r.oldYearNum) + '年'
                }
                return t + '/' + showData
            } else if (r.goodsType == 2) {
                // 系统恢复
                return '系统恢复'
            } else if (r.goodsType == 3) {
                // 反审（次）
                return '反审（次）'
            } else if (r.goodsType == 4) {
                // 反审（年）
                return '反审（年）'
            }
          }
        },
        {
          title: '付款方',
          align: "center",
          dataIndex: 'userId_dictText'
        },
        {
          title: '支付时间',
          align: "center",
          dataIndex: 'payTime'
        },
        {
          title: '支付方式',
          align: "center",
          dataIndex: 'payType_dictText'
        },
        {
          title: '支付金额',
          align: "center",
          dataIndex: 'payMoney',
          customRender: function (t, r, index) {
            return '￥' + t
          }
        },
        // {
        //   title: '支付状态',
        //   align: "center",
        //   dataIndex: 'payStatus_dictText'
        // },
        // {
        //   title: '备注',
        //   align: "center",
        //   dataIndex: 'note',
        //   scopedSlots: { customRender: 'noteSlot' }
        // },
        // {
        //   title: '操作',
        //   align: "center",
        //   dataIndex: 'action',
        //   scopedSlots: { customRender: 'action' }
        // },
      ],
      url: {
        list: "/XghAuthorizationCenter/xghAuthorizationCenterOrders/getOrderListByAccountBookId",
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: {
        xghAccountBookId: this.$route.query.id
      },
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    handleEdit(record) {
      console.log('编辑', record)
    },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'orderNumber', text: '订单编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'userId', text: '用户id', dictCode: '' })
      fieldList.push({ type: 'int', value: 'payType', text: '支付方式：1.微信 2.支付宝', dictCode: 'authorization_center_pay_type' })
      fieldList.push({ type: 'int', value: 'orderStatus', text: '订单状态：1.待付款 2.支付中，3.已完成 4.支付失败', dictCode: 'authorization_center_order_status' })
      fieldList.push({ type: 'datetime', value: 'payTime', text: '支付时间' })
      fieldList.push({ type: 'BigDecimal', value: 'orderMoney', text: '应收金额', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'payMoney', text: '实收金额', dictCode: '' })
      fieldList.push({ type: 'string', value: 'goodsName', text: '商品名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'goodsId', text: '商品id', dictCode: '' })
      fieldList.push({ type: 'int', value: 'goodsType', text: '商品类型：1.账套（版本） 2.用户数 3.云备份数', dictCode: 'authorization_center_goods_type' })
      fieldList.push({ type: 'int', value: 'goodsNumber', text: '商品数量（账套默认年，用户数默认无单位，云备份单位个）', dictCode: '' })
      fieldList.push({ type: 'int', value: 'paySecret', text: '支付密钥（用于银盛支付回调验证）', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';


.title_blue{
  font-size: 16px;
font-family: PingFang SC-Semibold, PingFang SC;
font-weight: 600;
color: #1B94FB;
}

.title_black{
  font-size: 17px;
font-family: PingFang SC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
margin-top: 30px;
}

.divider_line{
  background-color: #1B94FB;
  width: 100%;
  height: 2px;
  margin: 15px 0;
}

</style>